home *** CD-ROM | disk | FTP | other *** search
/ MacSilverWare / macsilverware.iso / Screen Savers / DarkSide 4.0 / FaderShell / Fader.h < prev    next >
Text File  |  1993-06-01  |  5KB  |  129 lines

  1. #ifndef __FADER__
  2. #define __FADER__
  3. /*
  4.     DarkSide 4.0 - a 7.0 dependant, system clean expandable screen saver.
  5.     
  6.     copyright © 1990, 1991, 1992, 1993 by Tom Dowdy
  7.     All rights reserved.
  8.     
  9.     This header file defines the interface between DarkSide and one of
  10.     its faders.
  11.  
  12. */
  13.  
  14. #ifndef __TYPES__
  15.     #include <Types.h>
  16. #endif
  17. #ifndef __OSUTILS__
  18.     #include <OSUtils.h>
  19. #endif
  20. #ifndef __QUICKDRAW__
  21.     #include <QuickDraw.h>
  22. #endif
  23. #ifndef __SOUND__
  24.     #include <Sound.h>
  25. #endif
  26.  
  27. #define    preflightFader        0
  28. #define initializeFader        1
  29. #define idleFader            2
  30. #define disposeFader        3
  31. #define updateFader            4
  32. #define hitFader            5
  33.  
  34. // info about a screen
  35. typedef struct
  36.     {
  37.     Rect        bounds;                    // bounds of that screen within our window
  38.     Boolean        isColor;                // color or bw/gray
  39.     short        depth;                    // depth in pixels
  40.     GDHandle    theDevice;                // device that goes with that screen
  41.     
  42.     short        originalDepth;            // depth before any changes
  43.     short        originalFlags;            // original device flags
  44.     short        whichFlagsChanged;        // which flags we changed
  45.     
  46.     Handle        screenGamma;            // copy of the screen's original gamma table
  47.     short        brightness;                // current monitor brightness (0-255)
  48.     short        newBrightness;            // new monitor brightness to set (0-255)
  49.     } ScreenInfo, *ScreenInfoPtr;
  50.         
  51. // storage for the user's settings
  52. #define numShorts    20
  53. #define numStrings    4
  54. typedef struct
  55.     {
  56.     short                theShorts[numShorts];
  57.     Str255                theStrings[numStrings];
  58.     } SettingsBlock, *SettingsPtr;
  59.  
  60. // currently supported options
  61. #define keyAndMouseUnfade        0x0001    // 0 if fader is allowing keystrokes/mouse motion
  62. #define faderRequestsUnfade        0x0002    // 1 if fader wishes to cause an unfade
  63. #define faderRequestsNoWindow     0x0004    // 1 if fader wishes no fade window
  64. #define ignoreModifierKeys        0x0008    // 1 if fader wishes us to ignore modifiers
  65.  
  66. // info about the machine
  67. typedef struct
  68.     {
  69.     SysEnvRec        theEnvirons;        // info about the machine
  70.     WindowPtr        fadeWindow;            // where the fade is taking place
  71.     Ptr                applicationQD;        // app QuickDraw globals
  72.     long            applicationA5;        // A5 for the application
  73.     long            faderOptions;        // options for the fader to give to DarkSide
  74.     SettingsPtr        faderSettings;        // user's settings for the fader
  75.     DialogPtr        settingsDialog;        // dialog with the settings
  76.     short            soundVolume;        // volume set by the user
  77.     SndChannelPtr    faderChannel;        // sound channel allocated for fader's use
  78.     Ptr                callbackLoader;        // segment loader for the callbacks
  79.     
  80.     short                numScreens;            // how many screens there are
  81.     ScreenInfo            theScreens[20];        // info about each screen
  82.     } MachineInfoRec, *MachineInfoPtr;
  83.     
  84.  
  85. // typedefs for the standard fader entry points    
  86. OSErr    PreflightFader(MachineInfoPtr machineInfo, long *minTicks, long *maxTicks);
  87. OSErr    InitializeFader(MachineInfoPtr machineInfo);
  88. OSErr    IdleFader(MachineInfoPtr machineInfo);
  89. OSErr    DisposeFader(MachineInfoPtr machineInfo);
  90. OSErr    UpdateFader(MachineInfoPtr machineInfo);
  91. OSErr    HitFader(MachineInfoPtr machineInfo, DialogPtr dPtr, short itemHit, short itemOffset);
  92.  
  93.  
  94. // Utilities
  95. Handle    BestNewHandle(Size theSize);
  96. RgnHandle    BestNewRgn();
  97. short Rnd(long max);
  98. void PlaceRectOnScreen(
  99.     MachineInfoPtr machineInfo,    // give info about the machine here
  100.     short width,                // width of rect, can be 0
  101.     short height,                // height of rect, can be 0
  102.     Rect * placedRect,            // Placed rect is returned here
  103.     Rect * margins,                // margins around screen, can be nil
  104.     short * whichScreen);        // screen index returned here, can be nil
  105.  
  106. // Utilities that utilize callbacks into DarkSide
  107.  
  108. // Calls to read and write additional data to/from the preferences file.  
  109. // WritePreferencesHandle disposes of the handle passed in
  110. // The handle returned by ReadPreferencesHandle should be disposed of by the caller
  111. OSErr    WritePreferencesHandle(MachineInfoPtr machineInfo, Handle h, ResType theType);
  112. OSErr    ReadPreferencesHandle(MachineInfoPtr machineInfo, Handle *h, ResType theType);
  113.  
  114. // play a 'snd ' with the specified resource ID through the sound channel created
  115. // by the 'Chnl' resource (if present).  Does nothing if a 'Chnl' is not present, or
  116. // if the user set the volume to zero
  117. OSErr    PlayResourceSnd(MachineInfoPtr machineInfo, short theID, Boolean async);
  118.  
  119.  
  120. /* ------------------------------------------------------------------------------------    */
  121. /*    Useful macros for your fader                                                         */
  122. /* ------------------------------------------------------------------------------------    */
  123. #define TopLeft(aRect)    (* (Point *) &(aRect).top)
  124. #define BotRight(aRect)    (* (Point *) &(aRect).bottom)
  125. #define RectWidth(r) (short)((r)->right - (r)->left)
  126. #define RectHeight(r) (short)((r)->bottom - (r)->top)
  127.  
  128. #endif __FADER__
  129.